package com.ruoyi.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.AhhcDepartmentAuthorization;
import com.ruoyi.system.service.IAhhcDepartmentAuthorizationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 患者可下拉选择并添加/删除Controller
 *
 * @author ruoyi
 * @date 2025-03-14
 */
@RestController
@RequestMapping("/system/authorization")
public class AhhcDepartmentAuthorizationController extends BaseController
{
    @Autowired
    private IAhhcDepartmentAuthorizationService ahhcDepartmentAuthorizationService;

    /**
     * 查询患者可下拉选择并添加/删除列表
     */
    @PreAuthorize("@ss.hasPermi('system:authorization:list')")
    @GetMapping("/list")
    public TableDataInfo list(AhhcDepartmentAuthorization ahhcDepartmentAuthorization)
    {
        startPage();
        List<AhhcDepartmentAuthorization> list = ahhcDepartmentAuthorizationService.selectAhhcDepartmentAuthorizationList(ahhcDepartmentAuthorization);
        return getDataTable(list);
    }

    /**
     * 导出患者可下拉选择并添加/删除列表
     */
    @PreAuthorize("@ss.hasPermi('system:authorization:export')")
    @Log(title = "患者可下拉选择并添加/删除", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AhhcDepartmentAuthorization ahhcDepartmentAuthorization)
    {
        List<AhhcDepartmentAuthorization> list = ahhcDepartmentAuthorizationService.selectAhhcDepartmentAuthorizationList(ahhcDepartmentAuthorization);
        ExcelUtil<AhhcDepartmentAuthorization> util = new ExcelUtil<AhhcDepartmentAuthorization>(AhhcDepartmentAuthorization.class);
        util.exportExcel(response, list, "患者可下拉选择并添加/删除数据");
    }

    /**
     * 获取患者可下拉选择并添加/删除详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:authorization:query')")
    @GetMapping(value = "/{patientPhone}")
    public AjaxResult getInfo(@PathVariable("patientPhone") String patientPhone)
    {
        return success(ahhcDepartmentAuthorizationService.selectAhhcDepartmentAuthorizationByPatientPhone(patientPhone));
    }

    /**
     * 新增患者可下拉选择并添加/删除
     */
    @PreAuthorize("@ss.hasPermi('system:authorization:add')")
    @Log(title = "患者可下拉选择并添加/删除", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AhhcDepartmentAuthorization ahhcDepartmentAuthorization)
    {
        return toAjax(ahhcDepartmentAuthorizationService.insertAhhcDepartmentAuthorization(ahhcDepartmentAuthorization));
    }

    /**
     * 修改患者可下拉选择并添加/删除
     */
    @PreAuthorize("@ss.hasPermi('system:authorization:edit')")
    @Log(title = "患者可下拉选择并添加/删除", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AhhcDepartmentAuthorization ahhcDepartmentAuthorization)
    {
        return toAjax(ahhcDepartmentAuthorizationService.updateAhhcDepartmentAuthorization(ahhcDepartmentAuthorization));
    }

    /**
     * 删除患者可下拉选择并添加/删除
     */
    @PreAuthorize("@ss.hasPermi('system:authorization:remove')")
    @Log(title = "患者可下拉选择并添加/删除", businessType = BusinessType.DELETE)
	@DeleteMapping("/{patientPhones}")
    public AjaxResult remove(@PathVariable String[] patientPhones)
    {
        return toAjax(ahhcDepartmentAuthorizationService.deleteAhhcDepartmentAuthorizationByPatientPhones(patientPhones));
    }
}
